package com.cyy.content.api;

import com.cyy.content.model.dto.CoursePreviewDto;
import com.cyy.content.service.CoursePublishService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.servlet.ModelAndView;

/**
 * @author cyy
 * @date 2025/2/14
 * @description CoursePublishController 课程预览， 发布
 */
@RestController
public class CoursePublishController {

    @Autowired
    CoursePublishService coursePublishService;



    @GetMapping("/coursepreview/{courseId}")
    public ModelAndView preview(@PathVariable("courseId") Long courseId){
        //获取课程预览信息
        CoursePreviewDto coursePreviewDto = coursePublishService.getCoursePreviewInfo(courseId);
        ModelAndView modelAndView = new ModelAndView();
        modelAndView.addObject("model", coursePreviewDto);
        modelAndView.setViewName("course_template");
        return modelAndView;
    }

    @ResponseBody
    @PostMapping("/courseaudit/commit/{courseId}")
    public void commitAudit(@PathVariable("courseId")Long courseId){
        Long companyId = 1232141425L;
        coursePublishService.commitAudit(courseId, companyId);
    }

    @ApiOperation("课程发布")
    @ResponseBody
    @PostMapping ("/coursepublish/{courseId}")
    public void coursePublish(@PathVariable("courseId")Long courseId){
        Long companyId = 1232141425L;
        coursePublishService.publish(companyId, courseId);
    }
}
